package com.ny.demo509;

import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;

public class Test {
    public static void main(String[] args) throws IOException {
        //存储文件内容
        String date ="今天是个好日子";
        FileOutputStream fileOutputStream = new FileOutputStream("1.txt");
        byte[] bytes = date.getBytes();
        fileOutputStream.write(bytes);
        //获取文件内容
        FileInputStream fis = new FileInputStream("1.txt");
        byte[] hhh =  new byte[1024];
        int bytesRead;
        StringBuilder content = new StringBuilder();
        while ((bytesRead = fis.read(hhh))!=-1){
            content.append(new String(hhh,0,bytesRead));

        }
        System.out.println("文件内容"+ content.toString());
}
}
